import { DELETE_CATEGORIES, EDIT_CATEGORIES, GET_CATEGORIES } from '@/store/categories/CONST'
import { Commit } from 'vuex'
import { State } from '@/store/categories/interface'
import { deleteCategories, editCategories, getCategories } from '@/api/categories'

export default {
  async [GET_CATEGORIES] (context: { commit:Commit }, param:{
    type: number,
    pagenum: number,
    pagesize: number
  }) {
    const data = await getCategories(param)
    context.commit(GET_CATEGORIES, data.data)
  },
  async [EDIT_CATEGORIES] (context:{commit:Commit}, param:{id:number, name:string}) {
    const res = editCategories(param)
    console.log(res)
  },
  async [DELETE_CATEGORIES] (context:{commit:Commit}, id:number) {
    const res = await deleteCategories(id)
    console.log(res)
  }

}
